//--------------------------------------------------------------------------------
//
//  Written by: Tyson Bailey
//
//  Date:
//
//  Purpose:
//
//
//  Notes:
//
//                    #  Who          Date
//  Revision History:
//--------------------------------------------------------------------------------

//#include "memory.h"

/*
*
*   1. Need register values, and value
*   2. Need memory values and value
*   3. Need to be able to "set any register"
*
*/



class simulation
{
private:        
        //Make the register's private. as well as instructions
        #include "registers.h"
        #include "instructions.h"
        //Members.
        string state; //Likely this will become an "enumerated type";
        
        double long getPMptr();     //getProgram Memory Pointer location
        int decodeAndRunInstruction(double long opration); //for single stepping
        int decodeAndRun();                           // for continuous running
        double long getInstruction();
        double long setInstruction();
        void setPMptr(double long val);           
public:

    // States will need to be "upload", continue, step
    // These will be the functions needed by the simulation.
    void setState();
    int getState();
    void upLoadFileToDevice(string file);
    void setPC(int to);
    int getPC();

    int start();
    void getGPRegisters();
    void getGPRegister(int regNum);
    void getSPRegisters();
    void getSPRegister(string regName);
    void setGPRegister(double long regNum, double long val);
    void setSPRegister(double long regNum, double long val);

    void getMemory(int from, int to);
    void getMemory(int location);

};




//Essentially this will be a state machine. and it's the "main" of the simulation
// this "class" should run on it's own thread, since it won't actually return to anyone,
// but a mechanism is needed to read the current state, possibly in a shared memory, that will
// tell it what the next state is.
int simulation::start()
{
    int state=0;
    int success=0;
    double long operation; // this is our actual operation in binary 32bit form assuming 
 while (1==1)
 { 
   state = getState();
   
   switch (state)
   {
    case 1: //stopped state
        break;
    case 2: //single step state
        operation = getInstruction();
        decodeAndRunInstruction(operation);
        setPC(getPC() +1);
        break;
    case 3: //Normal Operation
        decodeAndRun();
         break;
    case 4:
        //loading state
        
         break;  
    default:
         break;
          
   }
 }
}



/* Shell declarations, requiring work*/
void simulation::setState(){}
int simulation::getState(){return 0;}
void simulation::upLoadFileToDevice(string file){}
void simulation::setPC(int to){}
int simulation::getPC(){return 0;}

void simulation::getGPRegisters(){}
void simulation::getGPRegister(int regNum){}
void simulation::getSPRegisters(){}
void simulation::getSPRegister(string regName){}
void simulation::setGPRegister(double long regNum, double long val){}
void simulation::setSPRegister(double long regNum, double long val){}

int simulation::decodeAndRun(){return 0;}
int simulation::decodeAndRunInstruction(double long instruct){return 0;}
double long simulation::getInstruction(){return 0;}
void simulation::getMemory(int from, int to){}
void simulation::getMemory(int location){}
void setPMptr(double long val){}
